<?php
/**
 * Mechanism
 * 
 * LICENSE
 * 
 * This file is private intellectual property of the author. 
 * All rights reserved. Copying and illegal using is punishable by law.
 * 
 * @copyright Copyright (c) 2011 BreatheInMyVoid ( BreatheInMyVoid@gmail.com )
 */

 namespace Mechanism\Router\Route {
 	/**
 	 * Abstract route class
 	 * 
 	 * @package Route
 	 * @author BreatheInMyVoid ( BreatheInMyVoid@gmail.com )
 	 */
 	abstract class Route implements IRoute {
 		/**
 		 * Route module
 		 * 
 		 * @var string
 		 */
 		protected $module = null;
 		
 		/**
 		 * Route controller
 		 * 
 		 * @var string
 		 */
		protected $controller = null;
		
		/**
		 * Route action
		 * 
		 * @var string
		 */
		protected $action = null;
		
		/**
		 * Accept variables
		 * 
		 * @var bool
		 */
		protected $is_vars_enabled = false;
		
		/**
		 * Variables regex rule
		 * 
		 * @var string pattern
		 */
		protected $vars_regex = 'a-z0-9'; 		

		/**
		 * Variables array
		 *
		 * @var array
		 */
		protected $vars = array( );

		/**
		 * Assemble url
		 * 
		 * @param string
		 */
		protected abstract function assemble( $uri );
		
		/**
		 * Disassemble ulr
		 * 
		 * @param string
		 */
		protected abstract function disassemble( $uri );

 		/**
		 * Set module
		 * 
		 * @param string
		 */
		public function set_module( $module) {
			$this->module = $module;
			return $this;
		}

		/**
		 * Get module
		 * 
		 * @return string
		 */
		public function get_module( ) {
			if ( null === $this->module ) {
				throw new Exception( 'Module in route is null or not specified' );	
			} 
			
			return $this->module;
		}		
		
		/**
		 * Set controller
		 * 
		 * @param string
		 */
		public function set_controller( $controller ) {
			$this->controller = $controller;
			return $this;
		}

		/**
		 * Get controller
		 * 
		 * @return string
		 */
		public function get_controller( ) {
			if ( null === $this->controller ) {
				throw new Exception( 'Controller in route is null or not specified' );
			}
			
			return $this->controller;
		}

		/**
		 * Set action
		 * 
		 * @param string
		 */		
		public function set_action( $action ) {
			$this->action = $action;
			return $this;
		}

		/**
		 * Get action
		 * 
		 * @return string
		 */		
		public function get_action( ) {
			if ( null === $this->action ) {
				throw new Exception( 'Action in route is null or not specified' );
			}
			
			return $this->action;
		}	

		/**
		 * Get variables
		 *
		 * @return array
		 */
		public function get_vars( ) {
			return $this->vars;
		}
 	}
 }
